<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<title>bootstrap form</title>
<!-- Bootstrap core CSS -->
<link href="bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Optional Bootstrap Theme -->
<link href="data:text/css;charset=utf-8,"
	data-href="bootstrap-3.3.7-dist/css/bootstrap-theme.min.css"
	rel="stylesheet" id="bs-theme-stylesheet">

<!-- Bootstrap core JavaScript
		<!-- Placed at the end of the document so the pages load faster -->
<script src="jQuery Core 1.12.4/jquery-1.12.4.min.js"></script>
<script src="bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>

<script language="javascript" type="text/javascript">
	var code; //在全局定义验证码      
	//产生验证码     
	window.onload = function() {
		createCode();
	}

	function createCode() {
		code = "";
		var codeLength = 5; //验证码的长度     
		var checkCode = document.getElementById("checkCode");
		var random = new Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'A', 'B', 'C',
				'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
				'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'); //随机数     
		for (var i = 0; i < codeLength; i++) { //循环操作     
			var charIndex = Math.floor(Math.random() * 36); //取得随机数的索引     
			code += random[charIndex]; //根据索引取得随机数加到code上     
		}
		checkCode.value = code; //把code值赋给验证码     
	}
	//校验验证码     
	function validate() {
		var inputCode = document.getElementById("input1").value.toUpperCase(); //取得输入的验证码并转化为大写           
		if (inputCode.length <= 0) { //若输入的验证码长度为0     
			alert("请输入验证码！"); //则弹出请输入验证码     
			return false
		} else if (inputCode != code) { //若输入的验证码与产生的验证码不一致时     
			alert("验证码输入错误！"); //则弹出验证码输入错误     

			createCode(); //刷新验证码     
			return false
		} else { //输入正确时     
			alert("^-^"); //弹出^-^     
			return true
		}

	}
</script>
<style type="text/css">
    .code
     {
	      font-family: Arial;
	      font-style: italic;
	      color: Red;
	      border: 0;
	      padding: 2px 3px;
	      letter-spacing: 3px;
	      font-weight: bolder;
	    
}

    .unchanged
     {
	      border: 0;
	    
}
  
</style>
</head>

<body>
	<div class="container-fluid">
		<div class="row">
			<div class="col-md-12">
				<div class="row">
					<div class="col-md-3"></div>
					<div class="col-md-6">
						<form class="form-horizontal" action="${basePath}UserLoginServlet"
							method="post" onsubmit="return validate()">
							<div class="form-group"></div>
							<div class="form-group">
								<label for="inputEmail3" class="col-sm-2 control-label">姓名</label>
								<div class="col-sm-4">
									<input type="text" id="txtUserName" name="txtUserName"
										class="form-control" placeholder="请输入姓名">
								</div>

								<label for="inputEmail3" class="col-sm-2 control-label">密码</label>
								<div class="col-sm-4">
									<input type="password" id="txtUserPsw" name="txtUserPsw"
										class="form-control" placeholder="请输入密码">
								</div>
							</div>
							<div>
								<label class="col-sm-2 control-label" for="inputEmail">验证码</label> 
								<br />
								<input type="text" id="input1" class="form-control"/> 
								<br /> <input type="text" onclick="createCode()" readonly="readonly" id="checkCode"
									class="form-control" style="width: 80px; background: #C6C7C2" />
								<a href="#" onclick="createCode()">看不清楚（不区分大小写）</a>
							</div>

							<div class="form-group">
								<div class="col-sm-offset-2 col-sm-10">
									<button type="submit" class="btn btn-default">登录</button>
								</div>
							</div>
						</form>
					</div>
					<div class="col-md-3"></div>
				</div>
			</div>
		</div>
	</div>
</body>
</html>